<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module IRB::NestingParser - irb: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-open_tokens">::open_tokens</a>
    <li ><a href="#method-c-parse_by_line">::parse_by_line</a>
    <li ><a href="#method-c-scan_opens">::scan_opens</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-IRB::NestingParser">
    <h1 id="module-IRB::NestingParser" class="module">
      module IRB::NestingParser
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="IGNORE_TOKENS">IGNORE_TOKENS
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-open_tokens" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open_tokens</span><span
                                class="method-args">(tokens)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="open_tokens-source">
            <pre><span class="ruby-comment"># File irb/nesting_parser.rb, line 182</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">open_tokens</span>(<span class="ruby-identifier">tokens</span>)
  <span class="ruby-comment"># scan_opens without block will return a list of open tokens at last token position</span>
  <span class="ruby-identifier">scan_opens</span>(<span class="ruby-identifier">tokens</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse_by_line" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse_by_line</span><span
                                class="method-args">(tokens)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calculates token information [line_tokens, prev_opens, next_opens, min_depth] for each line. Example code</p>

<pre>[&quot;hello
world&quot;+(</pre>

<p>First line</p>

<pre>line_tokens: [[lbracket, &#39;[&#39;], [tstring_beg, &#39;&quot;&#39;], [tstring_content(&quot;hello\nworld&quot;), &quot;hello\n&quot;]]
prev_opens:  []
next_tokens: [lbracket, tstring_beg]
min_depth:   0 (minimum at beginning of line)</pre>

<p>Second line</p>

<pre>line_tokens: [[tstring_content(&quot;hello\nworld&quot;), &quot;world&quot;], [tstring_end, &#39;&quot;&#39;], [op, &#39;+&#39;], [lparen, &#39;(&#39;]]
prev_opens:  [lbracket, tstring_beg]
next_tokens: [lbracket, lparen]
min_depth:   1 (minimum just after tstring_end)</pre>

                              <div class="method-source-code" id="parse_by_line-source">
            <pre><span class="ruby-comment"># File irb/nesting_parser.rb, line 201</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse_by_line</span>(<span class="ruby-identifier">tokens</span>)
  <span class="ruby-identifier">line_tokens</span> = []
  <span class="ruby-identifier">prev_opens</span> = []
  <span class="ruby-identifier">min_depth</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">output</span> = []
  <span class="ruby-identifier">last_opens</span> = <span class="ruby-identifier">scan_opens</span>(<span class="ruby-identifier">tokens</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span>, <span class="ruby-identifier">opens</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">depth</span> = <span class="ruby-identifier">t</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">last</span>&amp;.<span class="ruby-identifier">first</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">min_depth</span> = <span class="ruby-identifier">depth</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">depth</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min_depth</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\n&quot;</span>)
      <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">line_tokens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-identifier">line</span>]
        <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;\n&quot;</span>
        <span class="ruby-identifier">next_opens</span> = <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:first</span>)
        <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">line_tokens</span>, <span class="ruby-identifier">prev_opens</span>, <span class="ruby-identifier">next_opens</span>, <span class="ruby-identifier">min_depth</span>]
        <span class="ruby-identifier">prev_opens</span> = <span class="ruby-identifier">next_opens</span>
        <span class="ruby-identifier">min_depth</span> = <span class="ruby-identifier">prev_opens</span>.<span class="ruby-identifier">size</span>
        <span class="ruby-identifier">line_tokens</span> = []
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">line_tokens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>]
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">line_tokens</span>, <span class="ruby-identifier">prev_opens</span>, <span class="ruby-identifier">last_opens</span>, <span class="ruby-identifier">min_depth</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">line_tokens</span>.<span class="ruby-identifier">any?</span>
  <span class="ruby-identifier">output</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-scan_opens" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">scan_opens</span><span
                                class="method-args">(tokens) { |t, opens| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Scan each token and call the given block with array of token and other information for parsing</p>

                              <div class="method-source-code" id="scan_opens-source">
            <pre><span class="ruby-comment"># File irb/nesting_parser.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">scan_opens</span>(<span class="ruby-identifier">tokens</span>)
  <span class="ruby-identifier">opens</span> = []
  <span class="ruby-identifier">pending_heredocs</span> = []
  <span class="ruby-identifier">first_token_on_line</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-identifier">last_tok</span>, <span class="ruby-identifier">state</span>, <span class="ruby-identifier">args</span> = <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">last</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">state</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:in_unquoted_symbol</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-constant">IGNORE_TOKENS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>)
        <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
        <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:in_lambda_head</span>
      <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_tlambeg</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_kw</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;do&#39;</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-value">:in_method_head</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-constant">IGNORE_TOKENS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>)
        <span class="ruby-identifier">next_args</span> = []
        <span class="ruby-identifier">body</span> = <span class="ruby-keyword">nil</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:receiver</span>)
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_lparen</span>, <span class="ruby-value">:on_ivar</span>, <span class="ruby-value">:on_gvar</span>, <span class="ruby-value">:on_cvar</span>
            <span class="ruby-comment"># def (receiver). | def @ivar. | def $gvar. | def @@cvar.</span>
            <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:dot</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_kw</span>
            <span class="ruby-keyword">case</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>
            <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;self&#39;</span>, <span class="ruby-string">&#39;true&#39;</span>, <span class="ruby-string">&#39;false&#39;</span>, <span class="ruby-string">&#39;nil&#39;</span>
              <span class="ruby-comment"># def self(arg) | def self.</span>
              <span class="ruby-identifier">next_args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-value">:arg</span>, <span class="ruby-value">:dot</span>)
            <span class="ruby-keyword">else</span>
              <span class="ruby-comment"># def if(arg)</span>
              <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">true</span>
              <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:arg</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_op</span>, <span class="ruby-value">:on_backtick</span>
            <span class="ruby-comment"># def +(arg)</span>
            <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">true</span>
            <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:arg</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_ident</span>, <span class="ruby-value">:on_const</span>
            <span class="ruby-comment"># def a(arg) | def a.</span>
            <span class="ruby-identifier">next_args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-value">:arg</span>, <span class="ruby-value">:dot</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:dot</span>)
          <span class="ruby-comment"># def receiver.name</span>
          <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_period</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_op</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;::&#39;</span>)
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:name</span>)
          <span class="ruby-keyword">if</span> <span class="ruby-node">%i[on_ident on_const on_op on_kw on_backtick]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>)
            <span class="ruby-comment"># def name(arg) | def receiver.name(arg)</span>
            <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:arg</span>
            <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:arg</span>)
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_nl</span>, <span class="ruby-value">:on_semicolon</span>
            <span class="ruby-comment"># def recever.f;</span>
            <span class="ruby-identifier">body</span> = <span class="ruby-value">:normal</span>
          <span class="ruby-keyword">when</span> <span class="ruby-value">:on_lparen</span>
            <span class="ruby-comment"># def recever.f()</span>
            <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:eq</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_op</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;=&#39;</span>
              <span class="ruby-comment"># def receiver.f =</span>
              <span class="ruby-identifier">body</span> = <span class="ruby-value">:oneliner</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-comment"># def recever.f arg</span>
              <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:arg_without_paren</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:eq</span>)
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_op</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;=&#39;</span>
            <span class="ruby-identifier">body</span> = <span class="ruby-value">:oneliner</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-identifier">body</span> = <span class="ruby-value">:normal</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:arg_without_paren</span>)
          <span class="ruby-keyword">if</span> <span class="ruby-node">%i[on_semicolon on_nl]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>)
            <span class="ruby-comment"># def f a;</span>
            <span class="ruby-identifier">body</span> = <span class="ruby-value">:normal</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-comment"># def f a, b</span>
            <span class="ruby-identifier">next_args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:arg_without_paren</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">body</span> <span class="ruby-operator">==</span> <span class="ruby-value">:oneliner</span>
          <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
        <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">body</span>
          <span class="ruby-identifier">opens</span>[<span class="ruby-value">-1</span>] = [<span class="ruby-identifier">last_tok</span>, <span class="ruby-keyword">nil</span>]
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">opens</span>[<span class="ruby-value">-1</span>] = [<span class="ruby-identifier">last_tok</span>, <span class="ruby-value">:in_method_head</span>, <span class="ruby-identifier">next_args</span>]
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:in_for_while_until_condition</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_semicolon</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_nl</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_kw</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;do&#39;</span>)
        <span class="ruby-identifier">skip</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_kw</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;do&#39;</span>
        <span class="ruby-identifier">opens</span>[<span class="ruby-value">-1</span>] = [<span class="ruby-identifier">last_tok</span>, <span class="ruby-keyword">nil</span>]
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">skip</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_kw</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;begin&#39;</span>, <span class="ruby-string">&#39;class&#39;</span>, <span class="ruby-string">&#39;module&#39;</span>, <span class="ruby-string">&#39;do&#39;</span>, <span class="ruby-string">&#39;case&#39;</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;end&#39;</span>
          <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;def&#39;</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-value">:in_method_head</span>, [<span class="ruby-value">:receiver</span>, <span class="ruby-value">:name</span>]]
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;if&#39;</span>, <span class="ruby-string">&#39;unless&#39;</span>
          <span class="ruby-keyword">unless</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">state</span>.<span class="ruby-identifier">allbits?</span>(<span class="ruby-constant">Ripper</span><span class="ruby-operator">::</span><span class="ruby-constant">EXPR_LABEL</span>)
            <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;while&#39;</span>, <span class="ruby-string">&#39;until&#39;</span>
          <span class="ruby-keyword">unless</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">state</span>.<span class="ruby-identifier">allbits?</span>(<span class="ruby-constant">Ripper</span><span class="ruby-operator">::</span><span class="ruby-constant">EXPR_LABEL</span>)
            <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-value">:in_for_while_until_condition</span>]
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;ensure&#39;</span>, <span class="ruby-string">&#39;rescue&#39;</span>
          <span class="ruby-keyword">unless</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">state</span>.<span class="ruby-identifier">allbits?</span>(<span class="ruby-constant">Ripper</span><span class="ruby-operator">::</span><span class="ruby-constant">EXPR_LABEL</span>)
            <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
            <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;elsif&#39;</span>, <span class="ruby-string">&#39;else&#39;</span>, <span class="ruby-string">&#39;when&#39;</span>
          <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;for&#39;</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-value">:in_for_while_until_condition</span>]
        <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;in&#39;</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">last_tok</span>&amp;.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_kw</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-node">%w[case in]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">last_tok</span>.<span class="ruby-identifier">tok</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">first_token_on_line</span>
            <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
            <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_tlambda</span>
        <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-value">:in_lambda_head</span>]
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_lparen</span>, <span class="ruby-value">:on_lbracket</span>, <span class="ruby-value">:on_lbrace</span>, <span class="ruby-value">:on_tlambeg</span>, <span class="ruby-value">:on_embexpr_beg</span>, <span class="ruby-value">:on_embdoc_beg</span>
        <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_rparen</span>, <span class="ruby-value">:on_rbracket</span>, <span class="ruby-value">:on_rbrace</span>, <span class="ruby-value">:on_embexpr_end</span>, <span class="ruby-value">:on_embdoc_end</span>
        <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_heredoc_beg</span>
        <span class="ruby-identifier">pending_heredocs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">t</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_heredoc_end</span>
        <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_backtick</span>
        <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">state</span>.<span class="ruby-identifier">allbits?</span>(<span class="ruby-constant">Ripper</span><span class="ruby-operator">::</span><span class="ruby-constant">EXPR_BEG</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_tstring_beg</span>, <span class="ruby-value">:on_words_beg</span>, <span class="ruby-value">:on_qwords_beg</span>, <span class="ruby-value">:on_symbols_beg</span>, <span class="ruby-value">:on_qsymbols_beg</span>, <span class="ruby-value">:on_regexp_beg</span>
        <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_tstring_end</span>, <span class="ruby-value">:on_regexp_end</span>, <span class="ruby-value">:on_label_end</span>
        <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:on_symbeg</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;:&#39;</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-value">:in_unquoted_symbol</span>]
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>]
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_nl</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:on_semicolon</span>
      <span class="ruby-identifier">first_token_on_line</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">!=</span> <span class="ruby-value">:on_sp</span>
      <span class="ruby-identifier">first_token_on_line</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">pending_heredocs</span>.<span class="ruby-identifier">any?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">tok</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\n&quot;</span>)
      <span class="ruby-identifier">pending_heredocs</span>.<span class="ruby-identifier">reverse_each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">opens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">t</span>, <span class="ruby-keyword">nil</span>] }
      <span class="ruby-identifier">pending_heredocs</span> = []
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">t</span>, <span class="ruby-identifier">opens</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">opens</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:first</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">pending_heredocs</span>.<span class="ruby-identifier">reverse</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

